#!/bin/bash
# postinst script for kernel-management

set -e

case "$1" in
    configure)
        # Set proper permissions
        chmod +x /usr/bin/kernel-management-cli
        chmod +x /usr/bin/kernel-management-gui
        chmod +x /usr/share/kernel-management/*.py
        
        # 创建桌面环境配置目录
        mkdir -p /etc/profile.d/
        
        # 添加环境变量配置
        cat > /etc/profile.d/kernel-management.sh << 'EOF'
#!/bin/bash
# Kernel Management GUI 环境变量设置
export QT_QPA_PLATFORMTHEME=gtk
EOF
        
        chmod +x /etc/profile.d/kernel-management.sh
        
        # Update desktop database
        if [ -x /usr/bin/update-desktop-database ]; then
            update-desktop-database /usr/share/applications/
        fi
        
        # Update icon cache
        if [ -x /usr/bin/update-icon-caches ]; then
            update-icon-caches /usr/share/icons/hicolor
        elif [ -x /usr/bin/gtk-update-icon-cache ]; then
            gtk-update-icon-cache -f /usr/share/icons/hicolor
        fi
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac
